include ../common.mk

CFLAGS_WRN:= -Wconversion -Wno-unused -Wno-strict-aliasing -Wextra

CFLAGS_IMGSRC  := -I$(SRC_PATH)
LDFLAGS_IMGSRC := $(LIB_PATH)/libimagesource.a -lm

CFLAGS = $(CFLAGS_STD) $(CFLAGS_UORC) $(CFLAGS_COMMON) $(CFLAGS_GLIB)  $(CFLAGS_LCM) $(CFLAGS_LCMTYPES) $(CFLAGS_IMGSRC) -D_GNU_SOURCE
LDFLAGS = $(LDFLAGS_STD) $(LDFLAGS_UORC) $(LDFLAGS_COMMON) $(LDFLAGS_GLIB) $(LDFLAGS_LCM) $(LDFLAGS_LCMTYPES)

# Test programs
DD_PUBLISH_TEST:=$(BIN_PATH)/diff_drive_test
IMTEST:=$(BIN_PATH)/im_test
TWO_NET_TEST:=$(BIN_PATH)/two_network_test
IR_SENSOR_TEST:=$(BIN_PATH)/irsensor_test
LASERPOINTER_TEST:=$(BIN_PATH)/laserpointer_test

BINARIES:=$(IMTEST) $(DD_PUBLISH_TEST) $(TWO_NET_TEST) $(IR_SENSOR_TEST) $(LASERPOINTER_TEST)

all: $(BINARIES)

$(IMTEST): imtest.o
	$(CC) -o $@ $^ $(LDFLAGS) $(LDFLAGS_IMGSRC) -ldc1394

$(TWO_NET_TEST): two_network_publisher.o
	$(CC) -o $@ $^ $(LDFLAGS)

$(IR_SENSOR_TEST): irsensor_test.o
	$(CC) -o $@ $^ $(LDFLAGS)

$(LASERPOINTER_TEST): laserpointer_test.o
	$(CC) -o $@ $^ $(LDFLAGS)

$(DD_PUBLISH_TEST): diff_publisher.o
	$(CC) -o $@ $^ $(LDFLAGS)

%.o: %.c
	@echo "    [$@]"
	$(CC) -c -o $@ $< $(CFLAGS)

clean:
	rm -f *.o $(BINARIES) *~

